import pinia from '@/stores';
import { useUserInfoStore } from '@/stores/userInfo';
import type { App } from 'vue';

export default function (app: App) {
  const userInfoStore = useUserInfoStore(pinia);

  app.directive('has', {
    mounted(el, binding) {
      //   debugger;
      // 如果value不在用户的按钮权限列表buttons中, 将当前el移除
      const buttons = userInfoStore.buttons;
      if (!buttons.includes(binding.value)) {
        el.parentNode.removeChild(el);
      }
    },
  });
}
